package handle

import (
	"github.com/hwcer/yyds/context"
	"github.com/hwcer/yyds/errors"
	"server/game/cache"
)

func init() {
	i := &Role{}
	Register(i.SetName, "role/setName/setName")
}

/**
 * @name setName
 * @param string name 新角色名
 * 角色改名
 */

func (r *Role) SetName(c *context.Context) any {
	name := c.GetString("name")
	if name == "" {
		return errors.ErrArgEmpty
	}
	doc := cache.GetRole(c.Player.Updater)
	doc.Set("name", name)
	return true
}
